<?php
// +----------------------------------------------------------------------
// | ZGUAN [ 致力于帮助更多的中小企业物联网转型 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.zguan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ZGUAN 并不是自由软件，未经许可不能去掉ZGUAN 相关版权
// +----------------------------------------------------------------------
// | Author: ZGUAN Team <admin@zguan.cn>  0769-82282996  15899929162
// +----------------------------------------------------------------------
namespace app\common\model\inspection;

use app\common\model\BaseModel;
use app\common\model\property\basic\PropertyBasicModel;

class InspectionSiteModel extends BaseModel
{


    public static function tablePk(): string
    {
        return 'id';
    }

    public static function tableName(): string
    {
        return 'inspection_site';
    }


    public function propertyInfo()
    {
        return $this->hasOne(PropertyBasicModel::class, 'id', 'property_id');
    }


    public function getAttrValueAttr($value)
    {
        return (array)json_decode($value, true);
    }

    /**
     * 获取详情地址
     * @return string
     */
    public function getCodeUrlAttr()
    {
        return request()->domain() . '/h5#/pages/devicehe/devicedata?site_id=' . $this->id;
    }

}
